package itdep.common.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Ivan Khalopik
 * @version $Revision: 4 $ $Date: 2010-06-10 13:13:16 +0000 (Thu, 10 Jun 2010) $
 */
public abstract class CollectionUtils {
	@SuppressWarnings({"unchecked"})
	public static <K, V> Map<K, V> arrayToMap(Object... objects) {
		if (objects == null || objects.length % 2 == 1) {
			throw new IllegalArgumentException("objects length must be ord");
		}
		Map<K, V> map = new HashMap<K, V>();
		for (int i = 0; i < objects.length; i += 2) {
			map.put((K) objects[i], (V) objects[i + 1]);
		}
		return map;
	}
}
